package com.tianbing.adlottery.controller.websiteadmin;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.jubao.ejb.business.WebsiteBusiness;
import com.jubao.ejb.entity.Website;
import com.tianbing.adlottery.helper.SkinUtils;

/**
 * MultiActionController for admin my store.
 * 
 * @author Conan Chen
 * @since 2007.12.15
 */
public class AdminWebsiteController extends MultiActionController {

	Logger logger = Logger.getLogger(AdminWebsiteController.class.getName());


	private String newRegisteredWebsiteListView;

	private WebsiteBusiness websiteBusiness;

	private SkinUtils skinUtils;

	public ModelAndView listNewRegisteredWebsite(HttpServletRequest request, HttpServletResponse response) throws Exception {

		ModelAndView mv = new ModelAndView(newRegisteredWebsiteListView);
		Map<String, Object> model = mv.getModel();

		// get site2content for this store
		Integer pgno = ServletRequestUtils.getIntParameter(request, "pgno", 0);
		Integer pgsize = ServletRequestUtils.getIntParameter(request, "pgsize", 30);

		List<Website> websiteList = websiteBusiness.getNewRegisteredWebsiteList(pgno, pgsize);
		long totalCount = websiteBusiness.getNewRegisteredWebsiteCount();
		model.put("websiteList", websiteList);

		int pageItemNum = websiteList == null ? 0 : websiteList.size();
		String otherParam = null;
		model = skinUtils
				.preparePageFooterParameters(request, pageItemNum, totalCount, pgno, pgsize, otherParam, model);

		return mv;
	}

	public void setLogger(Logger logger) {
		this.logger = logger;
	}

	/**
	 * @param newRegisteredWebsiteListView the newRegisteredWebsiteListView to set
	 */
	public void setNewRegisteredWebsiteListView(String newRegisteredWebsiteListView) {
		this.newRegisteredWebsiteListView = newRegisteredWebsiteListView;
	}

	/**
	 * @param websiteBusiness the websiteBusiness to set
	 */
	public void setWebsiteBusiness(WebsiteBusiness websiteBusiness) {
		this.websiteBusiness = websiteBusiness;
	}

	/**
	 * @param skinUtils the skinUtils to set
	 */
	public void setSkinUtils(SkinUtils skinUtils) {
		this.skinUtils = skinUtils;
	}


}
